home *** CD-ROM | disk | FTP | other *** search
- /*
- * MAINTMSG.C - Message maintenance
- *
- * Msged/Q message editor for QuickBBS Copyright 1990 by P.J. Muller
- *
- */
-
- #define TEXTLEN 200
-
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
-
- #include "msged.h"
- #include "screen.h"
- #include "qmsgbase.h"
-
- static int menu(void);
- static BOOLEAN copyto(BOOLEAN show);
- static BOOLEAN forward(void);
-
- /*
- * Show little menu at top
- */
-
- static int menu()
- {
- int ch;
-
- gotoxy(9, 1);
- clreol();
- set_color(co_hilite);
- bputc('M');
- set_color(co_normal);
- bputs("ove / ");
- set_color(co_hilite);
- bputc('C');
- set_color(co_normal);
- bputs("opy / Copy and ");
- set_color(co_hilite);
- bputc('S');
- set_color(co_normal);
- bputs("how or ");
- set_color(co_hilite);
- bputc('F');
- set_color(co_normal);
- bputs("orward this message? ");
- video_update();
- ch = getkey() & 0x7f;
- ch = tolower(ch); /* some tolower() implementations
- evaluate the argument twice (msc) */
- bputc((char) ch);
-
- return(ch);
- } /* menu */
-
- void movemsg()
- {
- int tmp;
-
- for (;;) {
- switch (menu()) {
-
- case 'c': (void)copyto(FALSE);
- return;
-
- case 's': (void)copyto(TRUE);
- return;
-
- case 'm': tmp = curmsg(CurBoard);
- if (copyto(FALSE))
- msgdelete(tmp,arealist[area].echomail,arealist[area].netmail);
- return;
-
- case 'f': (void)forward();
- return;
-
- case 27: return; /* escape */
-
- } /* switch */
- } /* forever */
- } /* movemsg */
-
- /*
- * Copy the current message to another board
- * Reads over current message
- * Returns TRUE if ok
- */
-
- static BOOLEAN copyto(BOOLEAN show)
- {
- int keeparea = area, newarea;
- BOOLEAN ok;
-
- newarea = selectarea("SELECT DESTINATION AREA"); /* destination area */
- area = keeparea; /* selectarea() might have changed it */
- if (newarea == -1)
- return FALSE; /* not copied */
-
- if (!readmsg(&message, curmsg(CurBoard)))
- return FALSE;
-
- #ifdef EIDS
- memset(&message.eid,0,sizeof(message.eid));
- #endif
- memset(&message.msgid,0,sizeof(message.msgid));
-
- if (show) {
- char org[TEXTLEN];
-
- sprintf(org, " * Copied from '%s' by %s\n",
- arealist[area].description, username);
- prependline("\n");
- prependline(org);
- } /* if */
-
- area = newarea; /* new area */
-
- clear_attributes(&message.header);
- message.header.msgnum = newmsgnum();
- message.header.reply = message.header.up = 0;
- message.header.board = CurBoard;
-
- ok = writemsg(&message);
-
- area = keeparea;
-
- return(ok);
- } /* copyto */
-
- static BOOLEAN forward()
- {
- char sfn[TEXTLEN];
- char dfn[TEXTLEN];
- char time[20], date[20];
- int keeparea = area, newarea;
- BOOLEAN ok;
-
- newarea = selectarea("SELECT DESTINATION AREA"); /* destination area */
- area = keeparea; /* restore it */
- if (newarea == -1)
- return TRUE;
-
- if (!readmsg(&message, curmsg(CurBoard)))
- return FALSE;
-
- timestr(time,date); /* get current time */
- sprintf(sfn," * Original to %s @ %s\n", message.header.to,
- formaddr(message.to,Z_A|N_A|P_O|D_O));
- sprintf(dfn," * Forwarded %s by %s @ %s\n",
- timedate(time, date, NO),
- username,
- formaddr(thisnode[arealist[newarea].aka],Z_A|N_A|P_O|D_O));
-
- area = newarea;
-
- clear_attributes(&message.header); /* looks at current area */
- message.header.msgnum = newmsgnum();
- message.header.reply = message.header.up = 0;
- message.header.board = CurBoard;
-
- prependline("\n"); /* forward header */
- prependline(dfn);
- prependline(sfn);
-
- editheader(); /* also resets eid */
-
- ok = writemsg(&message);
-
- area = keeparea;
-
- return(ok);
- } /* forward */
-
- static char maintmenu(void)
- {
- int ch;
-
- gotoxy(1, 1); clreol();
- bputs("Maintenance: ");
- set_color(co_hilite);
- bputc('D');
- set_color(co_normal);
- bputs("elete from current to last read in this area / ");
- set_color(co_hilite);
- bputs("Esc");
- set_color(co_normal);
- bputs(" to return: ");
- video_update();
- ch = getkey() & 0x7f;
- ch = tolower(ch); /* some tolower() implementations
- evaluate the argument twice (msc) */
- bputc((char) ch);
-
- return(ch);
- } /* maintmenu */
-
- static void delall(int delarea)
- {
- int num, last;
- BYTE board = arealist[delarea].board;
-
- scrollup(1,1,maxx,5,0);
-
- last = lastreadmsg(board);
- num = curmsg(board);
- if ((num <= 0) || (last <= 0)) return;
-
- gotoxy(3, 3);
- set_color(co_warn);
- bprintf("You are going to delete all messages from %d to %d in this area!",
- num, last);
- set_color(co_normal);
-
- if (!confirm(YES))
- return;
-
- while ((num <= last) && (num > 0)) {
- int next = msgnext(board, num);
-
- gotoxy(9,1);
- bprintf("Deleting message %d", num);
- clreol();
-
- if (keypressed())
- if (getkey() == ABORT)
- return;
-
- msgdelete(num,FALSE,FALSE); /* don't update tosslogs */
-
- if (next == num) break; /* reached end */
- num = next;
- } /* while */
-
- } /* delall */
-
- void maintarea()
- {
- for (;;) {
- switch (maintmenu()) {
-
- case 'd': delall(area);
- return;
-
- case 27: return; /* escape */
-
- } /* switch */
- } /* forever */
- } /* maintarea */